package mysqloperate;

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;

public class searchstu {
    public static Object[][] search() throws Exception {
        String sql="select * from student";
        connection con=new connection();
        Connection connection=con.getconnection();
        Statement statement=connection.createStatement();
        ResultSet rest=statement.executeQuery(sql);
        int count=0;
        while (rest.next()){
            count++;
        }
        Object[][] info=new Object[count][7];
        rest=statement.executeQuery(sql);
        count=0;
        while (rest.next()) {
            info[count][0] = rest.getString("studyid");
            info[count][1] = rest.getString("name");
            if(rest.getInt("sex")==1){
                info[count][2] = "男";
            }else{
                info[count][2] = "女";
            }
            info[count][3] = rest.getString("shengri");
            info[count][4] = rest.getInt("math");
            info[count][5] = rest.getInt("java");
            info[count][6] = rest.getInt("PE");
            count++;
        }
        rest.close();
        statement.close();
        connection.close();
        return info;
    }
    public static boolean youwuid(String id,Object[][] ob){
        for(int i=0;i<ob.length;i++)
        {
            if(id.equals(ob[i][0])){
                return true;
            }
        }
        return false;

    }
    public static boolean youwuid(String id) throws Exception {
        Object ob[][]=searchstu.search();
        for(int i=0;i<ob.length;i++)
        {
            if(id.equals(ob[i][0])){
                return true;
            }
        }
        return false;
    }
}
